#ifndef MYRESAMPLE_H
#define MYRESAMPLE_H

#include <mutex>

struct AVCodecParameters;
struct AVFrame;
struct SwrContext;

// 采样率一般为44100Hz, 若是采样率不符合，则需要重采样
// 重采样
class MYResample
{
public:
    MYResample();
    virtual ~MYResample();

    virtual bool Open(AVCodecParameters *para, bool isClearPara = false);
    virtual void Close();

    // 返回重采样后大小，不管成功与否都释放indata空间
    virtual int Resample(AVFrame *indata, unsigned char *d);

    //AV_SAMPLE_FMT_S16
    int outFormat = 1;

protected:
    std::mutex mux;
    // SwrContext 重采样结构体
    SwrContext *actx = 0;
};

#endif // MYRESAMPLE_H
